home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
8bit
/
cislib_b
/
utilde.p
< prev
next >
Wrap
Text File
|
1995-04-22
|
2KB
|
129 lines
PROGRAM UTILDEM(INPUT,OUTPUT);
VAR HWRK,KEY:^INTEGER; (* REQ FOR HELP *)
CNSL:INTEGER;
PROCEDURE INITHELP;
BEGIN
#A
LDA #$00
STA $2DC ; PLACE 0 IN REG 732
#
END;
(* INITHELP MUST BE CALLED AFTER
HELP=TRUE TO RESET *)
FUNCTION HELP:BOOLEAN;
BEGIN (* HELP KEY VALUE *)
HELP:=HWRK^=17;
END;
PROCEDURE FLUSHKBD;
BEGIN
#A
LDA #$FF
STA $2FC ; POKE 255 IN 764
#
END;
FUNCTION KEYPRESSED:BOOLEAN;
BEGIN
KEYPRESSED:=KEY^<>255;
END;
(* CONSOL DOES NOT NEED INIT.*)
FUNCTION CONSOL:INTEGER;_SP),Y
#
END;
FUNCTION RR2:INTEGER;
(* RETURNS AN INTEGER 0-255 *)
BEGIN
RR2:=0;
#A
LDA $D20A
LDY #5
STA (_SP),Y
INY
LDA #0
STA (_SP),Y
#
END;
FUNCTION RND(MIN,MAX:INTEGER):INTEGER;
(* RETURNS AN INTEGER >=MIN AND
<=MAX RANGE = MAXINT *)
VAR R,R1:REAL;
R2:INTEGER;
BEGIN
R:=(RR2 / 256);
R1:=((MAX-MIN+1)*R);
R2:=MIN+TRUNC(R1);
RND:=R2;
END;
PROCEDURE DELAY;
VAR V:INTEGER;
BEGIN FOR V:=1 TO 1000 DO (*ZIP*);END;
PROCEDURE DORAND;
VAR MINW,MAXW,I:INTEGER;
WRITE('ENTER MAX VALUE: ');
READLN(MAXW);
WRITELN;WRITELN;
WRITELN('HERE ARE SOME RANDOM NUMBERS:');
FOR I:=1 TO 20 DO
WRITE(RND(MINW,MAXW),' ');
WRITELN;
WRITELN;
END;
BEGIN
HWRK:=POINTER(732); (* HELP REG *)
KEY:=POINTER(764); (* KEY REG *)
INITHELP; FLUSHKBD;
WRITELN(' UTILDEM (c) 1987 S. ARMITAGE');
WRITELN('NIFTY (?) ROUTINES FOR KYAN PASCAL');
WRITELN(' KYAN PASCAL & LIB');
WRITELN(' (c) 1986 KYAN SOFTWARE INC.');
WRITELN;
WRITELN('PRESS HELP TO QUIT.');
WRITELN('PRESS ANY KEY FOR RANDOM INTEGERS.');
WRITELN('PRESS START,SELECT AND OPTION');
WRITELN('IN ANY COMBINATION TO TEST.');
REPEAT
DELAY;
CNSL:=CONSOL;
CASE CNSL OF
0:WRITELN('START+SELECT+OPTION');
1:WRITELN('OPTION+SELECT');
2:WRITELN('OPTION+START');
3:WRITELN('OPTION');
4:WRITELN('SELECT+START');
5:WRITELN('SELECT');
6:WRITELN('START');
7:(* NO CONSOL PRESSED *);
8:WRITELN(' CONSOL=8, VBLANK STAGE 2')
END;
IF KEYPRESSED THEN DORAND;
UNTIL HELP;
WRITELN;WRITELN;
FLUSHKBD; INITHELP;
END.